<template>
  <div style="overflow: hidden; height: 100vh; background: #fff; text-align: center;">
    <img style="margin: 20px 0;" src="../../assets/img/logo.png" alt="系统logo" />
    <el-menu :default-active="$route.path" style="border: none;">
      <div v-for="(item,index) in group" :key="index">
        <el-submenu v-if="item.sonPage!=null" :index="item.url">
          <template slot="title">
            <span>{{item.name}}</span>
          </template>
          <el-menu-item
            v-for="(son_item,son_index) in item.sonPage"
            :key="son_index"
            :index="son_item.url"
            @click="reUrl(son_item.url)"
          >
            <span>{{son_item.name}}</span>
          </el-menu-item>
        </el-submenu>
        <el-menu-item v-else :index="item.url" @click="reUrl(item.url)">
          <span>{{item.name}}</span>
        </el-menu-item>
      </div>
    </el-menu>
  </div>
</template>

<script>
export default {
  name: "aside-menu",
  data() {
    return {
      group: [],

    };
  },
  methods: {
    reUrl(url) {
      typeof url != undefined ? this.$router.push(url) : this.$router.go(0);
    }
  },
  mounted: function() {
    let vm = this;
    vm.$http({
      method: "get",
      url: "/api/url/getUrls"
    })
      .then(function(response) {
        if (response.data.code === 0) {
          vm.group = response.data.data;
          
          console.log(111);
          console.log(vm.group);
          console.log(vm.$route.path);
          console.log(111);
          
          
        } else {
          console.log("更新失败");
        }
      })
      .catch(function(error) {
        console.log(error);
      });
      
  }
};
</script>
<style>
.el-submenu__icon-arrow {
  margin-top: -5px;
}
</style>